﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

using WFL.Windows;

namespace WFL.Demo.WinForm
{
    public partial class StandardForm : Form
    {
        public StandardForm()
        {
            InitializeComponent();
        }

        protected override void SetClientSizeCore(int x, int y)
        {
            base.SetClientSizeCore(x, y);
        }

        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                default:
                    base.WndProc(ref m);
                    break;
                case Header.Winuser.WM_NCCALCSIZE:
                    {
                        if (m.WParam.ToInt32() == 0)
                        {
                            RECT rect = (RECT)m.GetLParam(typeof(RECT));
                        }
                        else
                        {
                            NCCALCSIZE_PARAMS ps = (NCCALCSIZE_PARAMS)m.GetLParam(typeof(NCCALCSIZE_PARAMS));
                            if (ps.Rgrc[0].Equals(ps.Rgrc[1]))
                            {

                            }
                        }
                        base.WndProc(ref m);
                        if (m.WParam.ToInt32() == 0)
                        {
                            RECT rect = (RECT)m.GetLParam(typeof(RECT));
                        }
                        else
                        {
                            NCCALCSIZE_PARAMS ps = (NCCALCSIZE_PARAMS)m.GetLParam(typeof(NCCALCSIZE_PARAMS));
                        }
                    }
                    break;
                case Header.Winuser.WM_GETMINMAXINFO:
                    {
                        MINMAXINFO minMaxInfo = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO));
                        base.WndProc(ref m);
                        minMaxInfo = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO));
                    }
                    break;
                case Header.Winuser.WM_WINDOWPOSCHANGING:
                    {
                        base.WndProc(ref m);
                        WINDOWPOS windowPos = (WINDOWPOS)m.GetLParam(typeof(WINDOWPOS));
                    }
                    break;
                case Header.Winuser.WM_NCACTIVATE:
                    {
                        base.WndProc(ref m);
                        //MessageBox.Show(m.Result.ToInt32().ToString());
                    }
                    break;
            }
        }

        private void _zoomOut_Click(object sender, EventArgs e)
        {
            Size = Size.Add(Size, new Size(100, 100));
        }

        private void _restoreBounds_Click(object sender, EventArgs e)
        {
            string text = "RestoreBounds:{0},{1}";
            text = string.Format(text, new object[]{
                    RestoreBounds.Width.ToString()
                    ,RestoreBounds.Height.ToString()
                    });
            MessageBox.Show(text);
        }

        private void _rectCheck_Click(object sender, EventArgs e)
        {
            string text = "Bounds:{0}\nClientRectangle:{1}";
            text = string.Format(text, new object[]{
                Bounds.ToString()
                ,ClientRectangle.ToString()
                });
            MessageBox.Show(text);
        }
    }
}
